package com.wxq.demo.dao;

import com.wxq.demo.pojo.Book;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class BookDao {
    @Resource(name = "jdbcTemplateOne")
    private JdbcTemplate jdbcTemplateOne;

    @Resource(name = "jdbcTemplateTwo")
    private JdbcTemplate jdbcTemplateTwo;

    public List<Book> findAllBooksFromDataSourceOne() {
        return jdbcTemplateOne.query("select * from book", new BeanPropertyRowMapper<>(Book.class));
    }

    public List<Book> findAllBooksFromDataSourceTwo() {
        return jdbcTemplateTwo.query("select * from book", new BeanPropertyRowMapper<>(Book.class));
    }
}
